package com.socket;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class WriteThread implements Runnable{
    private Socket socket;

    public WriteThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            while (true) {
                Scanner scanner = new Scanner(System.in);
                String str = scanner.nextLine();
                OutputStream os = socket.getOutputStream();
                os.write(str.getBytes());
                os.flush();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
